"""
@Author : 合肥一元数智教育科技有限公司
@Date :  2025/3/6 10:35
@Description :   写出数据到csv格式的文件

"""
import csv

csv_header = ['id', 'studentName', 'className', 'age']
csv_data1 = [1, 'zhangsan', 'python2511', 20]
csv_data2 = [2, 'lisi', 'python2511', 25]

csv_rows = [csv_header, csv_data1, csv_data2]

with open('dir01/test_student.csv', 'w',newline='') as csvfile:
    csvwriter = csv.writer(csvfile)
    # 通过csv写出对象 将数据写出到文件
    # csvwriter.writerow(csv_header)
    # csvwriter.writerow(csv_data1)
    # csvwriter.writerow(csv_data2)
    csvwriter.writerows(csv_rows)
